package cn.bugstack.mcp.server.niuke;

import cn.bugstack.mcp.server.niuke.domain.service.NiuKeArticleService;
import cn.bugstack.mcp.server.niuke.infrastructure.gateway.NiuKeService;
import cn.bugstack.mcp.server.niuke.types.properties.NiukeProperties;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.ai.tool.method.MethodToolCallbackProvider;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;

@SpringBootApplication
@Slf4j
public class McpServerApplication {

    @Resource
    private NiukeProperties niukeProperties;
    public static void main(String[] args) {
        SpringApplication.run(McpServerApplication.class, args);
    }

    @Bean
    public NiuKeService niuKeService(){
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("https://gw-c.nowcoder.com")
                .addConverterFactory(JacksonConverterFactory.create())
                .build();
        return  retrofit.create(NiuKeService.class);
    }

    @Bean
    public ToolCallbackProvider toolCallbackProvider(NiuKeArticleService niuKeArticleService){
        return MethodToolCallbackProvider.builder()
                .toolObjects(niuKeArticleService)
                .build();

    }

}
